package com.clock.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.clock.system.domain.SysBoss;
import com.clock.system.service.ISysBossService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.clock.common.annotation.Log;
import com.clock.common.core.controller.BaseController;
import com.clock.common.core.domain.AjaxResult;
import com.clock.common.enums.BusinessType;
import com.clock.common.utils.poi.ExcelUtil;
import com.clock.common.core.page.TableDataInfo;

/**
 * 商户信息Controller
 *
 * @author clock
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/system/boss")
public class SysBossController extends BaseController
{
    @Autowired
    private ISysBossService sysBossService;

    /**
     * 查询商户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:boss:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBoss sysBoss)
    {
        startPage();
        List<SysBoss> list = sysBossService.selectSysBossList(sysBoss);
        return getDataTable(list);
    }

    /**
     * 导出商户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:boss:export')")
    @Log(title = "商户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBoss sysBoss)
    {
        List<SysBoss> list = sysBossService.selectSysBossList(sysBoss);
        ExcelUtil<SysBoss> util = new ExcelUtil<SysBoss>(SysBoss.class);
        util.exportExcel(response, list, "商户信息数据");
    }

    /**
     * 获取商户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:boss:query')")
    @GetMapping(value = "/{bossId}")
    public AjaxResult getInfo(@PathVariable("bossId") Long bossId)
    {
        return success(sysBossService.selectSysBossByBossId(bossId));
    }

    /**
     * 新增商户信息
     */
    @PreAuthorize("@ss.hasPermi('system:boss:add')")
    @Log(title = "商户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBoss sysBoss)
    {
        return toAjax(sysBossService.insertSysBoss(sysBoss));
    }

    /**
     * 修改商户信息
     */
    @PreAuthorize("@ss.hasPermi('system:boss:edit')")
    @Log(title = "商户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBoss sysBoss)
    {
        return toAjax(sysBossService.updateSysBoss(sysBoss));
    }

    /**
     * 删除商户信息
     */
    @PreAuthorize("@ss.hasPermi('system:boss:remove')")
    @Log(title = "商户信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{bossIds}")
    public AjaxResult remove(@PathVariable Long[] bossIds)
    {
        return toAjax(sysBossService.deleteSysBossByBossIds(bossIds));
    }
}